<template>
	<view>
		<view class="bg" @click="goNav('/pages/my/userinfo')">
			<view>个人信息</view>
			<view class="flex align-center">
				<view style="font-weight: 500;color: #333333;font-size: 28rpx;margin-right: 20rpx;">去上传</view>
				<image src="../../static/images/my/right.png" style="width: 16rpx;height: 25rpx;"></image>
			</view>
		</view>
		<view class="bg" @click="goRenZheng">
			<view>身份认证</view>
			<view class="flex align-center">
				<view style="font-weight: 500;color: #333333;font-size: 28rpx;margin-right: 20rpx;">去上传</view>
				<image src="../../static/images/my/right.png" style="width: 16rpx;height: 25rpx;"></image>
			</view>
		</view>
		<view class="bg" @click="goNav('/pages/my/userinfo')">
			<view>头像/相册</view>
			<view class="flex align-center">
				<view style="font-weight: 500;color: #333333;font-size: 28rpx;margin-right: 20rpx;">去上传</view>
				<image src="../../static/images/my/right.png" style="width: 16rpx;height: 25rpx;"></image>
			</view>
		</view>
		<view class="bg" @click="goRenZheng">
			<view>资质信息</view>
			<view class="flex align-center">
				<view style="font-weight: 500;color: #333333;font-size: 28rpx;margin-right: 20rpx;">去上传</view>
				<image src="../../static/images/my/right.png" style="width: 16rpx;height: 25rpx;"></image>
			</view>
		</view>
		<view class="bg" @click="show = true">
			<view>出行方式</view>
			<view class="flex align-center">
				<view style="font-weight: 500;color: #333333;font-size: 28rpx;margin-right: 20rpx;" v-if="tripWay == 0">
					去上传</view>
				<view style="font-weight: 500;color: #333333;font-size: 28rpx;margin-right: 20rpx;" v-if="tripWay != 0">
					<!-- {{tripWay == 1 ? '公交' ? tripWay == 2 : '出租'}} -->
					<text v-if="tripWay == 1">公交</text>
					<text v-if="tripWay == 2">出租</text>
					<text v-if="tripWay == 3">免费</text>
					</view>
				<image src="../../static/images/my/right.png" style="width: 16rpx;height: 25rpx;"></image>
			</view>
		</view>
		<u-action-sheet :list="cxList" v-model="show" @click="cxCallback"></u-action-sheet>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tripWay: 0,
				show: false,
				renzheng: 0,
				cxList: [{
						text: '公交',
						label: 1
					},
					{
						text: '出租',
						label: 2
					},
					{
						text: '免费',
						label: 3
					}
				]
			}
		},
		onShow() {
			this.getUserInfo();
			this.getArtificer();
		},
		methods: {
			//获取技师的信息
			getArtificer() {
				this.$Request.getT("/app/artificer/selectArtificer").then(res => {
					if (res.code == 0) {
						this.tripWay = res.data.tripWay ? res.data.tripWay : 0;
					}
				});
			},
			cxCallback(index) {
				console.log(index)
				this.setChuXing(index + 1)
			},
			setChuXing(tripWay) {
				this.$queue.showLoading('设置中...')
				this.$Request.postT("/app/artificer/updateArtificerTripWay?tripWay=" + tripWay).then(res => {
					uni.hideLoading();
					if (res.code == 0) {
						this.$queue.showToast('设置成功！');
						this.getArtificer();
					}else{
						this.$queue.showToast(res.msg);
					}
				});
			},
			goRenZheng() {
				if (this.renzheng == 0) {
					uni.navigateTo({
						url: '/my/renzheng/index'
					});
				} else if (this.renzheng != 0) {
					if(this.renzheng == 1){
						this.$queue.showToast('实名认证系统审核中,请耐心等待');
					}else{
						uni.navigateTo({
							url: '/my/renzheng/index'
						});
					}
				}
			},
			getUserInfo() {
				this.$Request.get("/app/user/selectUserById").then(res => {
					if (res.code == 0) {
						if (res.data.isAuthentication == 0 || res.data.isAuthentication == null) {
							this.renzheng = 0
							uni.setStorageSync("renzheng", this.renzheng)
						} else if (res.data.isAuthentication == 1) {
							this.renzheng = 1
							uni.setStorageSync("renzheng", this.renzheng)
						} else if (res.data.isAuthentication == 2) {
							this.renzheng = 2
							uni.setStorageSync("renzheng", this.renzheng)
						} else if (res.data.isAuthentication == 3) {
							this.renzheng = 3
							uni.setStorageSync("renzheng", this.renzheng)
						} else if (res.data.isAuthentication == 4) {
							this.renzheng = 4
							uni.setStorageSync("renzheng", this.renzheng)
						} else if (res.data.isAuthentication == 5) {
							this.renzheng = 5
							uni.setStorageSync("renzheng", this.renzheng)
						} else if (res.data.isAuthentication == 6) {
							this.renzheng = 6
							uni.setStorageSync("renzheng", this.renzheng)
						}

					}
				});
			},
			goNav(e) {
				uni.navigateTo({
					url: e
				})
			},
		}
	}
</script>

<style>
	page {
		background: #F5F5F5;
	}

	.bg {
		background: #FFFFFF;
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 30rpx;
		padding: 40rpx 30rpx;
		font-size: 32rpx;
		font-weight: bold;
		font-family: PingFang SC;
	}
</style>
